//
//  CommentListCell.m
//  ShrimpCrowdordering
//
//  Created by 郑洲 on 2018/7/27.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "CommentListCell.h"

@interface CommentListCell ()

@property (nonatomic, strong) UIImageView *headView;
@property (nonatomic, strong) UILabel *nameLabel;

@property (nonatomic, strong) UIImageView *goodsView;
@property (nonatomic, strong) UILabel *goodsName;
@property (nonatomic, strong) UILabel *commentLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UILabel *commentDate;

@end

@implementation CommentListCell

+ (CommentListCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"WishTableViewCell";
    CommentListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[CommentListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = TABLEVIEW_BACKGROUNDCOLOR;
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {

    UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(50), ScreenX375(343), ScreenX375(100))];
    baseView.backgroundColor = REXADECIMALCOLOR(@"#f4f4f4");
    
    self.headView = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(91), ScreenX375(56), ScreenX375(30), ScreenX375(30))];
    self.headView.clipsToBounds = YES;
    self.headView.layer.cornerRadius = ScreenX375(15);
    self.headView.image = ImageWithName(@"头像1");
    [baseView addSubview:self.headView];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(131), ScreenX375(64), ScreenX375(100), ScreenX375(15))];
    self.nameLabel.textColor = REXADECIMALCOLOR(@"#212121");
    self.nameLabel.font = Kfont(14);
    self.nameLabel.text = @"南有佳人";
    [baseView addSubview:self.nameLabel];
    
    self.goodsView = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(10), ScreenX375(14), ScreenX375(72), ScreenX375(72))];
    self.goodsView.image = ImageWithName(@"2");
    self.goodsView.layer.cornerRadius = ScreenX375(8);
    self.goodsView.clipsToBounds = YES;
    [baseView addSubview:self.goodsView];
    
    self.goodsName = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(91), ScreenX375(16), ScreenX375(140), ScreenX375(14))];
    self.goodsName.textColor = REXADECIMALCOLOR(@"#212121");
    self.goodsName.font = Kfont(14);
    self.goodsName.text = @"设计生活，设计美，独特创意简约欧美风";
    [baseView addSubview:self.goodsName];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(91), ScreenX375(36), ScreenX375(140), ScreenX375(12))];
    self.detailLabel.textColor = REXADECIMALCOLOR(@"#888888");
    self.detailLabel.font = Kfont(12);
    self.detailLabel.text = @"女 · 青年 · 秋 · 外套";
//    [baseView addSubview:self.detailLabel];
    
    self.commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(23), ScreenX375(23), SCREEN_WIDTH - ScreenX375(100), ScreenX375(15))];
    self.commentLabel.textColor = REXADECIMALCOLOR(@"#4a90e2");
    self.commentLabel.font = Kfont(15);
    self.commentLabel.text = @"我的评论：超级喜欢饭饭的设计作品！";
    [self addSubview:self.commentLabel];
    
    self.commentDate = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(279), ScreenX375(24), ScreenX375(80), ScreenX375(12))];
    self.commentDate.textColor = REXADECIMALCOLOR(@"#888888");
    self.commentDate.font = Kfont(12);
    self.commentDate.textAlignment = NSTextAlignmentRight;
    self.commentDate.text = @"2018-08-11";
    [self addSubview:self.commentDate];
    
    [self addSubview:baseView];
}

- (void)setProCommentModel:(ProCommentModel *)proCommentModel {
    _proCommentModel = proCommentModel;
    
    [self.headView sd_setImageWithURL:[NSURL URLWithString:proCommentModel.proUserPic] placeholderImage:nil options:SDWebImageRetryFailed];
    self.nameLabel.text = proCommentModel.proUserName;
    [self.goodsView sd_setImageWithURL:[NSURL URLWithString:proCommentModel.proPic] placeholderImage:nil options:SDWebImageRetryFailed];
    self.goodsName.text = proCommentModel.proName;
    self.commentLabel.text = [NSString stringWithFormat:@"我的评论：%@",proCommentModel.content];
    self.commentDate.text = [HttpManager getTime:[HttpManager TimeStamp:proCommentModel.createTime]];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation ProCommentModel

+(JSONKeyMapper*)keyMapper
{
    return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{
                                                                  @"Id": @"id"
                                                                  }];
}


@end
